<script setup lang="ts">

import { useRouter } from 'vue-router';

import InFo from "./components/index";

import { ref } from 'vue';

import { useListStore } from "./stores/counter";

const listMenu = useListStore()


const router = useRouter();

const list: any = ref(JSON.parse(localStorage.getItem('menu') as string))

console.log(list.value);

if (list.value.length) {
  //默认显示
  const mnu = list.value[0]
  console.log(mnu);
  router.addRoute('home', {
    path: '',
    name: 'leve',
    component: InFo[mnu['component']]
  })


  // 载入全部路由
  list.value.forEach((item: any) => {
    console.log(item);
    router.addRoute('home', {
      path: item.path,
      name: item.name,
      component: InFo[item.component]
    })
  });

  console.log(router.getRoutes());

  listMenu.increment(list.value)

  console.log(location.pathname);

  router.push(location.pathname)


}
</script>

<template>
  <RouterView></RouterView>
</template>

<style scoped>

</style>

